package com.ac.core.dm;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright JieRuanShiJi 2004</p>
 * <p>Company: JieRuanShiJi</p>
 * @author <a href="mailto:lianzs@tom.com">Lianzs</a>
 * @version 1.0
 */

public abstract class BaseDm implements Serializable {
    public String toString() {
        return doToString();
    }

    public boolean equals(Object object) {
        if (this == object) {
            return true;
        }
        if (object == null) {
            return false;
        }
        if (getClass() != object.getClass()) {
            return false;
        }
        return doEquals(object);
    }

    public int hashCode() {
        return doHashCode();
    }

    protected String doToString() {
        return super.toString();
    }

    protected abstract boolean doEquals(Object object);

    protected abstract int doHashCode();

    protected final String defaultToString() {
        return ToStringBuilder.reflectionToString(this,
                                                  ToStringStyle.
                                                  MULTI_LINE_STYLE);
    }

    protected final boolean defaultEquals(Object object) {
        return EqualsBuilder.reflectionEquals(this, object);
    }

    protected final int defaultHashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    protected final ToStringBuilder getToStringBuilder() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
    }

    protected final EqualsBuilder getEqualsBuilder() {
        return new EqualsBuilder();
    }

    protected final HashCodeBuilder getHashCodeBuilder() {
        return new HashCodeBuilder();
    }
}
